Skip to content

Correctly centering text on rectangular devices#85

Merged
hatl merged 1 commit intohatl:masterfrom
alexpetroaica:fix/display-correctly-on-rectangular-devices
Jul 20, 2025
Merged

Correctly centering text on rectangular devices#85
hatl merged 1 commit intohatl:masterfrom
alexpetroaica:fix/display-correctly-on-rectangular-devices

Conversation

@alexpetroaica
Copy link

BEFORE:
before

AFTER:
after

if (Utils.isRectangularScreen()) {
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK);
dc.drawText(vh * 0.65, cvw, font, text, Graphics.TEXT_JUSTIFY_CENTER);
dc.drawText(cvw, vh * 0.4, font, text, Graphics.TEXT_JUSTIFY_CENTER);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the docs, the width is the first argument, not the height, which was causing some trouble (see screenshots i added to the PR)

dc.drawText(cvw, vh * 0.4, font, text, Graphics.TEXT_JUSTIFY_CENTER);
} else {
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK);
dc.drawText(cvh, cvw, font, text, Graphics.TEXT_JUSTIFY_CENTER);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to touch this one because I assumed you tested on non-rectangular devices, but it should probably be fixed too as the arguments are passed the wrong way around

@hatl
Copy link
Owner

hatl commented Jul 10, 2025

Thank you for your contributions!
I hope that I'll be able to check and merge them during the weekend.

ghost

This comment was marked as resolved.

@hatl hatl dismissed ghost ’s stale review July 20, 2025 07:44

not a reviewer

@hatl hatl merged commit 10051fd into hatl:master Jul 20, 2025
1 check passed
Salvio93 pushed a commit to Salvio93/hasscontrol that referenced this pull request Jan 4, 2026
Authored-by: alexpetroaica <!alexandru.petroaica@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants